import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';

enum Api {
  pageCheckBatch = "/pay-service/checkBatch/page",
  getCheckBatch = "/pay-service/checkBatch/get",
  refreshCheck = "/pay-service/checkBatch/refreshCheck",
  deleteCheckBatch = "/pay-service/checkBatch/delete",
  batchDeleteCheckBatch = "/pay-service/checkBatch/batchDelete",
}

export const getCheckBatch = (params) => {
  return defHttp.get({url : Api.getCheckBatch, params});
}

export const pageCheckBatch = (params) => {
  return defHttp.get({url : Api.pageCheckBatch, params});
}

/**
 * 重新对账
 */
export const refreshCheck = (params) => {
  return defHttp.put({url: Api.refreshCheck, params}, {joinParamsToUrl: true});
}

export const deleteCheckBatch = (params, handleSuccess) => {
  return defHttp.delete({url: Api.deleteCheckBatch, data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

export const batchDeleteCheckBatch = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.batchDeleteCheckBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
